<?php
// 售后审核图片上传
define('IN_ECS', true);

    require(dirname(__FILE__) . '/includes/init.php');
    // include_once(ROOT_PATH .'includes/cls_json.php');
    // $json = new JSON();
    //初始返回数据
    $return['error']="0";
    $return['content']="";

    //允许上传类型
    $uptypes=array(
        'image/jpg',
        'image/jpeg',
        'image/png',
        'image/pjpeg',
        'image/gif',
        'image/bmp',
        'image/x-png'
        );
    $max_file_size=2000000;     //上传文件大小限制, 单位BYTE
    $url="sale_pic/"; //上传文件路径
    $file = $_FILES["file"]; //获取文件
    $filename=$file["tmp_name"];
    if(!in_array($file["type"], $uptypes))
    //检查文件类型
    {
        $return['error']="1";
        $return['content']="图片格式不正确!";
        die(json_encode($return));
    }
    //检查上传目录是否存在
    if(!file_exists($url))
    {
        //创建目录
        mkdir($url);
    }

    $filename=$file["tmp_name"];
    $image_size = getimagesize($filename);
    $pinfo=pathinfo($file["name"]);
    $ftype=$pinfo['extension'];
    $img_name=time().".".$ftype;
    $destination = ROOT_PATH . $url . $img_name; //上传图片地址
    $destination2 = $url.$img_name; //上传图片地址

    if(!move_uploaded_file($filename,$destination) || !FTP()->upload($destination, $destination2))//判断是否移动成功
    {
        $return['error']="1";
        $return['content']="移动失败";
        die(json_encode($return));
    }
    sleep(1);
    $return['error']="2";
    $return['content']="移动成功";
    $return['pic']=$destination2;
    die(json_encode($return));




 ?>